#include "label.h"
#include <QMouseEvent>
#include <QDebug>

Label::Label(QWidget* parent):QLabel(parent)
{

}

void Label::mousePressEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton){
        qDebug()<<"left";
    }else if(event->button()==Qt::RightButton){
        qDebug()<<"right";
    }

    //当前event对象就包含了鼠标点击位置的坐标
    //坐标原点是当前label这个控件
    qDebug()<<event->x()<<","<<event->y()<<Qt::endl;

    //坐标原点是当前整个屏幕
    qDebug()<<event->globalX()<<","<<event->globalY()<<Qt::endl;
    qDebug()<<event->globalPos();
}

void Label::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton){
        qDebug()<<"release left";
    }
    else if(event->button()==Qt::RightButton){
        qDebug()<<"release right";
    }
}

void Label::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton){
        qDebug()<<"left double click";
    }
    else if(event->button()==Qt::RightButton){
        qDebug()<<"right double click";
    }

}
